    <?php $this->load->view('user/user_head');?>

<script type="text/javascript">
<!--
$(function() {

	$(".m_check_box").each(function() {
		if (this.checked) {
			$('#' + this.name).attr('disabled', 'disabled').css('background-color', "#efefec");
			$('#' + 'tr_' + this.name).css('background-color', "#efefec").css('color', '#d8d7d3');
		} 
	});


	
	$(".m_check_box").click(function() {
		if (this.checked) {
			$('#' + this.name).attr('disabled', 'disabled').css('background-color', "#efefec");
			$('#' + 'tr_' + this.name).css('background-color', "#efefec").css('color', '#d8d7d3');
		} else {
			$('#' + this.name).attr('disabled', '').css('background-color', "#fff");
			$('#' + 'tr_' + this.name).css('background-color', "#feeffe").css('color', '#444444');
		}
	});

	
	$("input[type*='text']").blur(function() {
		var val = $(this).val();

		if ($.trim(val) != '') {
			var patrn=/\d/;   
			if (!patrn.exec(val)) {
				$(this).css('background-color', "#faf0c7");
				alert("请输入[0-9]的数字");
			} else {
				$(this).css('background-color', "#fff");
			}
		} else {
			$(this).css('background-color', "#fff");
		}
	}); 

	
	$('.calc_button').click(function() {
		cacl();
	});

	$('#save_button').click(function() {
		var sum_m = cacl();
		if (sum_m != 0) {
			var data = {};
			for (var i = 1; i < 16; i++) {
				if ($('#f_' + i + "_flag").attr('checked')) {
					eval('data.f_' + i + '_flag = 1') ;
				} else {
					eval('data.f_' + i + '_flag = 0') ;
				}
				if ($.trim($('#f_' + i).val()) != '') {
					eval('data.f_' + i + ' = ' + $.trim($('#f_' + i).val())) ;
				} else {
					eval('data.f_' + i + '  = 0');
				}
			}
			eval('data.date= new Date();');
			eval('data.sum_m = ' + sum_m +';');
			var url = "<?php echo base_url();?>index.php/user/budgetAction/ajax_save";
			//alert(JSON.stringify(data));
			$.post(url, data, function(x) {
				alert(x);
			});
		}

		
	});
});

function cacl() {
	var count = 0;
	for (var i = 1; i < 16; i++) {
		if (!$('#f_' + i + "_flag").attr('checked')) {
			if ($.trim($('#f_' + i).val()) != '') {
				count += parseInt($('#f_' + i).val());
			}
		}
	}
	if (count == 0) {
		$('#calc_result').html('尚未填写各项费用!');
	} else {
		$('#calc_result').html('您的婚礼预算消费:<i style="color:red;font-size:14px">'+ count +'</i>元');
	}
	return count;
}
//-->

</script>   
    <input type="hidden" id="page_code" value="2"/>
    <!-- begin: main content area #main -->
     <div id="main">
      <!-- begin: #col1 - first float column -->
      <div id="col1" role="complementary">
		<div class="my_box" style="margin-top:10px;">
          <p class="box_title"><span>婚礼预算</span></p>
		  	 <div class="left_nav" style="margin:20px 0 20px 10px;">
			 	<ul>
			 		<li><a href="#">如何合理预算婚礼！</a></li>
			 		<li><a href="#">婚礼预算案例！</a></li>
			 		<li><a href="#">网友预算心的！</a></li>
			 	</ul>
			 </div>
		</div>      
	  </div>
      <!-- end: #col1 -->
      <!-- begin: #col3 static column -->
      <div id="col3" role="main">
        <div id="col3_content" class="clearfix">
           <div class="sys_help_msg_box" style="height:100px;margin-bottom:10px;">
	        	<p style="margin:20px 10px 0 20px;"><strong style="color:#d02200">温馨提示:</strong>
	        		预算婚礼费用、看看应该花费多少银两；我们还为您提供了 <a href="#">选婚礼礼服</a>
	        		<a href="#">租婚礼用车</a>
	        		<a href="#">找好庆典公司</a>等等服务! 
	        	</p>
            </div>
           
           <div class="my_box">
            <p class="box_title"><span>婚礼费用预算</span></p>
           		
           		 <div style="margin:20px 0 0 20px;">
           		 	<button class="calc_button" style="padding:0 20px;">计算</button>
           		 	<button id="save_button" style="padding:0 20px;">保存</button>
           		 	<p id="calc_result" style="margin:10px 0 0 20px;">
           		 	<?php if (isset($budget)):?>
           		 	您的婚礼预算消费:<i style="color:red;font-size:14px"><?php echo $budget['sum_m'];?></i>元;
           		 	<?php endif;?>
           		 	</p>
           		 </div>
            
   				 <div style="margin:20px;">

          		 <table  class="datalist" summary="婚礼预算费用列表" id="oTable" >
          		 
	          		<tr>
						<th scope="col" width="30%">类型</th>
						<th scope="col" width="20%">费用</th>
						<th scope="col" width="8%">略</th>
						<th scope="col" width="40%">帮助</th>
					</tr>
					
					<tr>
						<td colspan="4" align="cenger"><strong>服装饰品类</strong></td>
					</tr>
					
					<tr id="tr_f_1">
						<td>婚纱礼服费用：</td>
						<td><input type="text" class="money_input" maxlength="5" id="f_1" value="<?php echo isset($budget) ?  $budget['f_1'] :  "";?>"/></td>
						<?php if (isset($budget)):?>
						<td><input class="m_check_box" type="checkbox" id="f_1_flag" name="f_1" <?php echo $budget['f_1_flag']==1 ? "checked='checked'" : "";?>/></td>
						<?php endif;?>
						<?php if (!isset($budget)):?>
						<td><input class="m_check_box" type="checkbox" id="f_1_flag" name="f_1"/></td>
						<?php endif;?>
						<td><a href="#">选婚纱礼服</a></td>
					</tr>
					
					<tr id="tr_f_2">
						<td>钻戒首饰费用：</td>
						<td><input type="text" class="money_input" maxlength="6" id="f_2" value="<?php echo isset($budget) ?  $budget['f_2'] :  "";?>"/></td>
						<?php if (isset($budget)):?>
						<td><input class="m_check_box" type="checkbox" id="f_2_flag" name="f_2" <?php echo $budget['f_2_flag']==1 ? "checked='checked'" : "";?>/></td>
						<?php endif;?>
						<?php if (!isset($budget)):?>
						<td><input class="m_check_box" type="checkbox" id="f_2_flag" name="f_2"/></td>
						<?php endif;?>
						<td><a href="#">选钻戒首饰</a></td>
					</tr>
					
					<tr id="tr_f_3">
						<td>新娘化妆费用：</td>
						<td><input type="text" class="money_input" maxlength="4" id="f_3" value="<?php echo isset($budget) ?  $budget['f_3'] :  "";?>"/></td>
						<?php if (isset($budget)):?>
						<td><input class="m_check_box" type="checkbox" id="f_3_flag" name="f_3" <?php echo $budget['f_3_flag']==1 ? "checked='checked'" : "";?>/></td>
						<?php endif;?>
						<?php if (!isset($budget)):?>
						<td><input class="m_check_box" type="checkbox" id="f_3_flag" name="f_3"/></td>
						<?php endif;?>
						<td><a href="#">找金牌化妆师</a></td>
					</tr>
					<tr>
						<td colspan="4" align="cenger"><strong>庆典类</strong></td>
					</tr>
					
					<tr id="tr_f_4">
						<td>婚庆公司费用：</td>
						<td><input type="text" class="money_input" maxlength="6" id="f_4" value="<?php echo isset($budget) ?  $budget['f_4'] :  "";?>"/></td>
						<?php if (isset($budget)):?>
						<td><input class="m_check_box" type="checkbox" id="f_4_flag" name="f_4" <?php echo $budget['f_4_flag']==1 ? "checked='checked'" : "";?>/></td>
						<?php endif;?>
						<?php if (!isset($budget)):?>
						<td><input class="m_check_box" type="checkbox" id="f_4_flag" name="f_4"/></td>
						<?php endif;?>
						<td><a href="#">找金牌服务婚庆公司</a></td>
					</tr>
					<tr id="tr_f_5">
						<td>头车费用：</td>
						<td><input type="text" class="money_input" maxlength="6" id="f_5" value="<?php echo isset($budget) ?  $budget['f_5'] :  "";?>"/></td>
						<?php if (isset($budget)):?>
						<td><input class="m_check_box" type="checkbox" id="f_5_flag" name="f_5" <?php echo $budget['f_5_flag']==1 ? "checked='checked'" : "";?>/></td>
						<?php endif;?>
						<?php if (!isset($budget)):?>
						<td><input class="m_check_box" type="checkbox" id="f_5_flag" name="f_5"/></td>
						<?php endif;?>
						<td><a href="#">找婚车头车</a></td>
					</tr>
					
					<tr id="tr_f_6">
						<td>其他车辆费用：</td>
						<td><input type="text" class="money_input" maxlength="6" id="f_6" value="<?php echo isset($budget) ?  $budget['f_6'] :  "";?>"/></td>
						<?php if (isset($budget)):?>
						<td><input class="m_check_box" type="checkbox" id="f_6_flag" name="f_6" <?php echo $budget['f_6_flag']==1 ? "checked='checked'" : "";?>/></td>
						<?php endif;?>
						<?php if (!isset($budget)):?>
						<td><input class="m_check_box" type="checkbox" id="f_6_flag" name="f_6"/></td>
						<?php endif;?>
						<td><a href="#">找婚车</a></td>
					</tr>
					
					<tr id="tr_f_7">
						<td>邀请司仪费用：</td>
						<td><input type="text" class="money_input" maxlength="5" id="f_7" value="<?php echo isset($budget) ?  $budget['f_7'] :  "";?>"/></td>
						<?php if (isset($budget)):?>
						<td><input class="m_check_box" type="checkbox" id="f_7_flag" name="f_7" <?php echo $budget['f_7_flag']==1 ? "checked='checked'" : "";?>/></td>
						<?php endif;?>
						<?php if (!isset($budget)):?>
						<td><input class="m_check_box" type="checkbox" id="f_7_flag" name="f_7"/></td>
						<?php endif;?>
						<td><a href="#">找最棒的司仪</a></td>
					</tr>
					
					<tr id="tr_f_8">
						<td>摄像、摄影师费用：</td>
						<td><input type="text" class="money_input" maxlength="4" id="f_8" value="<?php echo isset($budget) ?  $budget['f_8'] :  "";?>"/></td>
						<?php if (isset($budget)):?>
						<td><input class="m_check_box" type="checkbox" id="f_8_flag" name="f_8" <?php echo $budget['f_8_flag']==1 ? "checked='checked'" : "";?>/></td>
						<?php endif;?>
						<?php if (!isset($budget)):?>
						<td><input class="m_check_box" type="checkbox" id="f_8_flag" name="f_8"/></td>
						<?php endif;?>
						<td><a href="#">找高水准的摄像、摄影师</a></td>
					</tr>
					
					<tr id="tr_f_9">
						<td>邀请乐队费用：</td>
						<td><input type="text" class="money_input" maxlength="5" id="f_9" value="<?php echo isset($budget) ?  $budget['f_9'] :  "";?>"/></td>
						<?php if (isset($budget)):?>
						<td><input class="m_check_box" type="checkbox" id="f_9_flag" name="f_9" <?php echo $budget['f_9_flag']==1 ? "checked='checked'" : "";?>/></td>
						<?php endif;?>
						<?php if (!isset($budget)):?>
						<td><input class="m_check_box" type="checkbox" id="f_9_flag" name="f_9"/></td>
						<?php endif;?>
						<td><a href="#">找最好的乐队</a></td>
					</tr>
					
					<tr>
						<td colspan="4" align="cenger"><strong>喜宴类：</strong></td>
					</tr>
					
					<tr id="tr_f_10">
						<td>酒店酒席费用：</td>
						<td><input type="text" class="money_input" maxlength="7" id="f_10" value="<?php echo isset($budget) ?  $budget['f_10'] :  "";?>"/></td>
						<?php if (isset($budget)):?>
						<td><input class="m_check_box" type="checkbox" id="f_10_flag" name="f_10" <?php echo $budget['f_10_flag']==1 ? "checked='checked'" : "";?>/></td>
						<?php endif;?>
						<?php if (!isset($budget)):?>
						<td><input class="m_check_box" type="checkbox" id="f_10_flag" name="f_10"/></td>
						<?php endif;?>
						<td><a href="#">定酒店</a></td>
					</tr>
					
					<tr id="tr_f_11">
						<td>喜烟喜酒费用：</td>
						<td><input type="text" class="money_input" maxlength="6" id="f_11" value="<?php echo isset($budget) ?  $budget['f_11'] :  "";?>"/></td>
						<?php if (isset($budget)):?>
						<td><input class="m_check_box" type="checkbox" id="f_11_flag" name="f_11" <?php echo $budget['f_11_flag']==1 ? "checked='checked'" : "";?>/></td>
						<?php endif;?>
						<?php if (!isset($budget)):?>
						<td><input class="m_check_box" type="checkbox" id="f_11_flag" name="f_11"/></td>
						<?php endif;?>
						<td><a href="#">选烟选酒</a></td>
					</tr>
					
					<tr id="tr_f_12">
						<td>糖果点心费用：</td>
						<td><input type="text" class="money_input" maxlength="4" id="f_12" value="<?php echo isset($budget) ?  $budget['f_12'] :  "";?>"/></td>
						<?php if (isset($budget)):?>
						<td><input class="m_check_box" type="checkbox" id="f_12_flag" name="f_12" <?php echo $budget['f_12_flag']==1 ? "checked='checked'" : "";?>/></td>
						<?php endif;?>
						<?php if (!isset($budget)):?>
						<td><input class="m_check_box" type="checkbox" id="f_12_flag" name="f_12"/></td>
						<?php endif;?>
						<td><a href="#">选糖果点心</a></td>
					</tr>
					
					<tr id="tr_f_13">
						<td>红包礼品费用：</td>
						<td><input type="text" class="money_input" maxlength="5" id="f_13" value="<?php echo isset($budget) ?  $budget['f_13'] :  "";?>"/></td>
						<?php if (isset($budget)):?>
						<td><input class="m_check_box" type="checkbox" id="f_13_flag" name="f_13" <?php echo $budget['f_12_flag']==1 ? "checked='checked'" : "";?>/></td>
						<?php endif;?>
						<?php if (!isset($budget)):?>
						<td><input class="m_check_box" type="checkbox" id="f_13_flag" name="f_13"/></td>
						<?php endif;?>
						<td><a href="#">选礼品</a></td>
					</tr>
					
					<tr>
							<td colspan="4" align="cenger"><strong>其他类：</strong></td>
					</tr>
					
					<tr id="tr_f_14">
						<td>蜜月旅游费用：</td>
						<td><input type="text" class="money_input" maxlength="5" id="f_14" value="<?php echo isset($budget) ?  $budget['f_14'] :  "";?>"/></td>
						<?php if (isset($budget)):?>
						<td><input class="m_check_box" type="checkbox" id="f_14_flag" name="f_14" <?php echo $budget['f_14_flag']==1 ? "checked='checked'" : "";?>/></td>
						<?php endif;?>
						<?php if (!isset($budget)):?>
						<td><input class="m_check_box" type="checkbox" id="f_14_flag" name="f_14"/></td>
						<?php endif;?>
						<td><a href="#">选路线 选景点</a></td>
					</tr>
					
					<tr id="tr_f_15">
						<td>其他费用：</td>
						<td><input type="text" class="money_input" maxlength="5" id="f_15" value="<?php echo isset($budget) ?  $budget['f_15'] :  "";?>"/></td>
						<?php if (isset($budget)):?>
						<td><input class="m_check_box" type="checkbox" id="f_15_flag" name="f_15" <?php echo $budget['f_15_flag']==1 ? "checked='checked'" : "";?>/></td>
						<?php endif;?>
						<?php if (!isset($budget)):?>
						<td><input class="m_check_box" type="checkbox" id="f_15_flag" name="f_15"/></td>
						<?php endif;?>						<td>&nbsp;</td>
					</tr>
          		 </table>
          		 
          			 <button class="calc_button" style="padding:0 20px">计算</button> 
			</div>
          </div>
        </div>
        <div id="ie_clearing">&nbsp;</div>
        <!-- End: IE Column Clearing -->
      </div>
      <!-- end: #col3 -->
    </div>
    
    <!-- end: #main -->
<?php $this->load->view('user/footer');?>